<?php
/*
if (!isset($modoBusqueda) || !$modoBusqueda){
    $contextMenu[0]["link"]      = "javascript:fn_nuevo()";
    $contextMenu[0]["linkIcon"]  = "application_add.png";
    $contextMenu[0]["linkTitle"] = "Nuevo almacen";
}
*/
$codigoBusqueda = "";
$nombreBusqueda = "";

if (array_key_exists('articuloId', $vars)) {
	$codigoBusqueda = $vars["articuloId"];
}elseif (array_key_exists('codigoBusqueda', $_POST)) {
	$codigoBusqueda = $_POST["codigoBusqueda"];
}

if (array_key_exists('almacenId', $vars)) {
	$nombreBusqueda = $vars["almacenId"];
}elseif (array_key_exists('nombreBusqueda', $_POST)) {
	$nombreBusqueda = $_POST["nombreBusqueda"];
}

?>
<script>
/*
 function fn_detalle(almacenId,articuloId){			
		   $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=Almacen&accion=shw&almacenId="+almacenId+"&articuloId="+articuloId, function(){
		   	
		   });
 }
*/			 
</script>
<body>
<div id="main">
  <?php include $_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/views/header.inc'; ?>
  <div id="zonaContenedor">
    <h3>.:: Movimientos de Stock </h3>
    <div>

	<form id='formItem' name='formItem' method="post" >    
		Articulo : <input type="text" name="articuloId" size="15" value="<?php echo $codigoBusqueda?>">
		Almacen : <input type="text" name="almacenId" size="25" value="<?php echo $nombreBusqueda?>">  
		<input type="submit" name="aceptar" value="aceptar" >    
	</form>         
		
		<table id="flex1" style="display:none"></table>
		<script type="text/javascript">
		$("#flex1").flexigrid({
			url: '/gourmet-express/trunk/src/index.php?do=StockMovimiento&accion=listarStockMovimiento',
			dataType: 'json',
			colModel : [
				//{display: 'DocId', name : 'docId', width : 100, sortable : true, align: 'left'},
				{display: 'Almacen', name : 'almacenId', width : 50, sortable : true, align: 'left'},
				{display: 'Articulo', name : 'articuloId', width : 60, sortable : true, align: 'left'},
                                {display: 'Fecha Movimiento', name : 'fechaMov', width : 100, sortable : true, align: 'left'},                                  
                                {display: 'SaldoAnt', name : 'saldoAnt', width : 60, sortable : true, align: 'left'},                                
				{display: 'I/S', name : 'ingSal', width : 20, sortable : true, align: 'left'},								
				{display: 'Tipo', name : 'movTipo', width : 30, sortable : true, align: 'left'},												
				{display: 'Cantidad', name : 'cant', width : 60, sortable : true, align: 'left'},												                                
                                {display: 'Costo', name : 'costo', width : 60, sortable : true, align: 'left'},												                                                                                                
				{display: 'DocNum', name : 'docNum', width : 100, sortable : true, align: 'left'},
				//{display: '&nbsp;', name : 'opciones', width : 80, sortable : true, align: 'right'}
				],
			searchitems : [
				{display: 'Almacen', name : 'almacenId'},
				{display: 'Articulo', name : 'articuloId', isdefault: true}
				],
			sortname: "almacenId",
			sortorder: "asc",
			usepager: true,
			title: 'Stock Movimiento',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			onSubmit: addFormData,
			height: 270
		});   
		
		
		//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
		function addFormData(){
			//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
			var dt = $('#formItem').serializeArray();
			$("#flex1").flexOptions({params: dt});
			return true;
		}
			
		$('#formItem').submit(function (){
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		});
		</script>
	</div>
	<div id="div_listar" align="center"></div>
	<div id="div_oculto" style="display: none;"></div>
  </div>      
</body>
<script>
//fn_buscar();
</script>